package com.ruoyi.project.qyxy;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.qyxy.enterprise.domain.EnterpriseInfo;
import com.ruoyi.project.qyxy.enterprise.service.IEnterpriseInfoService;
import com.ruoyi.project.qyxy.orgdtl.domain.OrgScoreDetail;
import com.ruoyi.project.qyxy.orgdtl.service.IOrgScoreDetailService;
import com.ruoyi.project.qyxy.person.domain.ZcPerson;
import com.ruoyi.project.qyxy.person.domain.ZzPerson;
import com.ruoyi.project.qyxy.person.service.IPersonService;
import com.ruoyi.project.qyxy.qua.domain.*;
import com.ruoyi.project.qyxy.qua.service.IQuaInfoService;
import com.ruoyi.project.qyxy.qua.service.IQuaPersionConfigService;
import com.ruoyi.project.qyxy.socre.domain.OrgScore;
import com.ruoyi.project.qyxy.socre.service.IOrgScoreService;
import com.ruoyi.project.tool.utils.DoubleUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service
public class SgEnterprise {

    //企业信息
    @Autowired
    private IEnterpriseInfoService enterpriseInfoService;

    //资质信息
    @Autowired
    private IQuaInfoService quaInfoService;

    //企业得分详细
    @Autowired
    private IOrgScoreDetailService orgScoreDetailService;

    @Autowired
    private IOrgScoreService orgScoreService;

    //人员信息
    @Autowired
    private IPersonService personService;

    //资质人员标准参数
    @Autowired
    private IQuaPersionConfigService quaPersionConfigService;

    /**
     * 企业得分类型 资质
     */
    private final String QUA_TYPE = "1";

    /**
     * 企业得分类型 人员
     */
    private final String PERSON_TYPE = "2";

    /**
     * 注册建造师类型分隔符
     */
    private final String REG_SPTY_S = "|";

    /**
     * 注册建造师级别分隔符
     */
    private final String REG_SPTY_D = ",";

    /**
     * 最高得分
     */
    private final Double MAX_SCORE = 6D;

    /**
     * 最低得分
     */
    private final Double MIN_SOCRE = 0D;

    /**
     * 每缺少一个人减少0.6分
     */
    private final Double SUBSTRACT_SCORE = 0.6;

    /**
     * 标准得分
     */
    private final Double STANDARD = 4.2;

    /**
     * 加分枚举
     */
    private enum ScoreEnum{
        FIRST("81",0.12),SECOND("82",0.06);

        ScoreEnum(String regTypeId, Double score) {
            this.regTypeId = regTypeId;
            this.score = score;
        }

        private String regTypeId;
        private Double score;

        public String getRegTypeId() {
            return regTypeId;
        }

        public void setRegTypeId(String regTypeId) {
            this.regTypeId = regTypeId;
        }

        public Double getScore() {
            return score;
        }

        public void setScore(Double score) {
            this.score = score;
        }
    }

//    @Scheduled(cron = "0 27 9 * * ?")
    public String test(){
        EnterpriseInfo enterpriseInfo = new EnterpriseInfo();
        enterpriseInfo.setQuaType("7");
        //查询资质得分规则
        List<QuaRule> quaRules = quaInfoService.selectQuaRuleList();
        //查询施工企业
        List<EnterpriseInfo> enterpriseList = enterpriseInfoService.selectEnterpriseInfoList(enterpriseInfo);
        for (EnterpriseInfo enterprise : enterpriseList) {
            QuaInfo quaInfo = new QuaInfo();
            quaInfo.setOrgCode(enterprise.getOrgCode());
            quaInfo.setQuaType("7");
            //查询资质集合
            List<QuaInfo> quaInfoList = quaInfoService.selectQuaInfoList(quaInfo);
            //计算资质得分
            Double quaScore = getQuaScore(quaRules, enterprise, quaInfoList);
            String orgName = enterprise.getOrgName();
            System.out.println("企业:"+orgName+",资质类别得分:"+quaScore+"分");
            //计算人员得分
            ArrayList<QuaTemp> quaTempList = new ArrayList<>();
            //填充计算信息
            fillQuaTempList(quaInfoList, quaTempList);
            //查询企业注册建造师
            List<ZzPerson> zzPersonList = personService.getZzPersonList(enterprise.getOrgCode());
            //查询企业职称人员
            List<ZcPerson> zcPersonList = personService.getZcPersonList(enterprise.getOrgCode());
            if(zzPersonList==null||zzPersonList.isEmpty()){
                //得0分
                System.out.println(enterprise.getOrgName()+":没有注册人员得 0分");
                //记录得分明细
                OrgScoreDetail orgScoreDetail = new OrgScoreDetail();
                orgScoreDetail.setType(PERSON_TYPE);
                orgScoreDetail.setOrgCode(enterprise.getOrgCode());
                orgScoreDetail.setScore(MIN_SOCRE);
                orgScoreDetailService.insertOrgScoreDetail(orgScoreDetail,new ArrayList<>());
                addOrgScore(enterprise);
                continue;
            }
            System.out.println("企业名称:["+enterprise.getOrgName()+"],组织机构代码证号:["+enterprise.getOrgCode()+"],资质信息计算:");
            //符合标准资质 --> 检验标准 --> 标准合格(不合格不做处理) --> 去除注册建造师 --> 去除职称人员 --> 更改资质状态为合格
            conformToQua(enterprise, quaTempList, zzPersonList, zcPersonList);
            //不符合标准 --> 筛选不合格资质 --> 去除注册建造师 --> 不合格记录缺少人数 --> 去除职称人员 --> 不合格记录缺少人员或类别
            inconformityQua(enterprise, quaTempList, zzPersonList, zcPersonList);
            //整体是否符合标准 --> 符合 --> 加分 --> 不符合 --> 扣分
            computeScore(enterprise, quaTempList, zzPersonList);
            //添加企业所有得分
            addOrgScore(enterprise);
        }
        return "";
    }


    /**
     * 包含注册人员
     * @param zzPerson
     * @param list
     * @return
     */
    private boolean containsZzPerson(ZzPerson zzPerson,List<ZzPerson> list){
        boolean flag = false;
        for (ZzPerson person : list) {
            if(zzPerson.getIdNum().equals(person.getIdNum())){
                flag = true;
            }
        }
        return flag;
    }

    /**
     * 添加企业所有得分
     * @param enterprise
     */
    private void addOrgScore(EnterpriseInfo enterprise) {
        Double sum = orgScoreDetailService.getSumScore(enterprise.getOrgCode());
        OrgScore orgScore = new OrgScore();
        orgScore.setOrgName(enterprise.getOrgName());
        orgScore.setOrgCode(enterprise.getOrgCode());
        orgScore.setFinalScore(sum);
        orgScore.setCreateTime(new Date());
        orgScoreService.insertOrgScore(orgScore);
    }

    /**
     * 计算最终得分
     * @param enterprise
     * @param quaTempList
     * @param zzPersonList
     */
    private void computeScore(EnterpriseInfo enterprise, ArrayList<QuaTemp> quaTempList, List<ZzPerson> zzPersonList) {
        Double score = STANDARD;
        boolean flag = allFlag(quaTempList);
        if(flag){
            Double addScoreTemp = score;
            //找出需要注册建造师人数最多的资质
            QuaTemp maxPersonQuaTemp = quaTempList.get(0);
            for (int i = 1; i < quaTempList.size(); i++) {
                QuaTemp temp = quaTempList.get(i);
                if(maxPersonQuaTemp.getHavePerson() < temp.getHavePerson()){
                    maxPersonQuaTemp = temp;
                }
            }
            //注册建造师类别处理临时集合
//            ArrayList<QuaPersonZzTemp> zzTempList = new ArrayList<>();
            List<ZzPerson> augmentZzPerson = maxPersonQuaTemp.getAugmentZzPersonList();
            //获取该资质规则
            //根据资质名称查询资质人员标准
            QuaPersionConfig quaPersionConfig = new QuaPersionConfig();
            quaPersionConfig.setQuaName(maxPersonQuaTemp.getQuaInfo().getQuaName());
            //资质人员标准参数
            List<QuaPersionConfig> quaPersionConfigList = quaPersionConfigService.selectQuaPersionConfigList(quaPersionConfig);
            QuaPersionConfig qpc = quaPersionConfigList.get(0);
            //去除资质已使用人员
            for (int i = 0; i < zzPersonList.size(); i++) {
                ZzPerson zzPerson = zzPersonList.get(i);
                List<ZzPerson> zzUsePersonList = maxPersonQuaTemp.getZzPersonList();
                for (ZzPerson zzUsePerson : zzUsePersonList) {
                    if(zzPerson.getIdNum().equals(zzUsePerson.getIdNum())){
                        zzPersonList.remove(i);
                        i--;
                        break;
                    }
                }
            }
            if(qpc.getRegNum() != null){
                //不区分类别 只要是注册建造师就加分
                for (int i = 0; i < zzPersonList.size(); i++) {
                    ZzPerson zzPerson = zzPersonList.get(i);
                    if(!containsZzPerson(zzPerson,augmentZzPerson)){
                        score = getAddScore(score, zzPerson);
                        augmentZzPerson.add(zzPerson);
                        zzPersonList.remove(i);
                        i--;
                    }
                }
//                String regSpty = qpc.getRegSpty();
//                if(StringUtils.isEmpty(regSpty)){
//
//                }else{
//                    formatRegSpty(regSpty, zzTempList);
//                    //区分类别 (类别和级别都要匹配)
//                    for (QuaPersonZzTemp quaPersonZzTemp : zzTempList) {
//                        String r = quaPersonZzTemp.getRegSpty();
//                        String g = quaPersonZzTemp.getRegSptyGrade();
//                        for (int i = 0; i < zzPersonList.size(); i++) {
//                            ZzPerson zzPerson = zzPersonList.get(i);
//                            String r1 = zzPerson.getRegSpty();
//                            String g1 = zzPerson.getRegTypeId();
//                            if(!StringUtils.isEmpty(r1)&&r1.contains(r)){
//                                if(StringUtils.isEmpty(g)){
//                                    //不需要判断级别 直接加分
//                                    score = getAddScore(score, zzPerson);
//                                    augmentZzPerson.add(zzPerson);
//                                    i--;
//                                }else{
//                                    //判断级别是否相同
//                                    if(!StringUtils.isEmpty(g1)&&g1.contains(g)){
//                                        //级别相同加分
//                                        score = getAddScore(score, zzPerson);
//                                        augmentZzPerson.add(zzPerson);
//                                        i--;
//                                    }
//                                }
//                            }
//                        }
//                    }
//                }


            }
            Double addScore = DoubleUtils.sub(score,addScoreTemp);
            maxPersonQuaTemp.setAddScore(addScore.toString());
        }else{
            Double reduceTemp = score;
            //找出缺少人员最多的资质
            Long count = 0L;
            //找出缺少人数最多的数量
            for (QuaTemp quaTemp : quaTempList) {
                if(!quaTemp.getQualified()){
                    Long shortOfCount = 0L;
                    //缺少注册人员
                    shortOfCount += quaTemp.getShortOfZzCount();
                    //缺少职称人员
                    shortOfCount += quaTemp.getShortOfZcCount();
                    //缺少职称人员类别
                    int zcType = quaTemp.getShortOfZcTypeList().size();
                    if(quaTemp.getShortOfZcCount() == 0){
                        shortOfCount += zcType;
                    }
                    if(shortOfCount > count){
                        count = shortOfCount;
                    }
                }

            }

            QuaTemp maxQuaTemp = null;
            for (QuaTemp quaTemp : quaTempList) {
                if(!quaTemp.getQualified()){
                    Long shortOfCount = 0L;
                    //缺少注册人员
                    shortOfCount += quaTemp.getShortOfZzCount();
                    //缺少职称人员
                    shortOfCount += quaTemp.getShortOfZcCount();
                    //缺少职称人员类别
                    int zcType = quaTemp.getShortOfZcTypeList().size();
                    if(quaTemp.getShortOfZcCount() == 0){
                        shortOfCount += zcType;
                    }
                    if(shortOfCount == count){
                        maxQuaTemp = quaTemp;
                    }
                }

            }
            //减分
            //缺少注册人员
            Long shortOfZzCount = maxQuaTemp.getShortOfZzCount();
            //缺少职称人员
            Long shortOfZcCount = maxQuaTemp.getShortOfZcCount();
            //缺少职称人员类别
            int zcType = maxQuaTemp.getShortOfZcTypeList().size();
            score = subtractScore(score,shortOfZzCount);
            score = subtractScore(score,shortOfZcCount);
            if(shortOfZcCount == 0){
                score = subtractScore(score, (long) zcType);
            }
            Double reduceScore = DoubleUtils.sub(reduceTemp,score);
            maxQuaTemp.setReduceScoer(reduceScore.toString());
//            for (QuaTemp quaTemp : quaTempList) {
//                if(!quaTemp.getQualified()){
//                    reduceTemp = score;
//                    //缺少注册人员
//                    Long shortOfZzCount = quaTemp.getShortOfZzCount();
//                    //缺少职称人员
//                    Long shortOfZcCount = quaTemp.getShortOfZcCount();
//                    //缺少职称人员类别
//                    int zcType = quaTemp.getShortOfZcTypeList().size();
//                    score = subtractScore(score,shortOfZzCount);
//                    score = subtractScore(score,shortOfZcCount);
//                    if(shortOfZcCount == 0){
//                        score = subtractScore(score, (long) zcType);
//                    }
//                    Double reduceScore = DoubleUtils.sub(reduceTemp,score);
//                    quaTemp.setReduceScoer(reduceScore.toString());
//                }
//
//            }
        }
        //记录得分明细
        OrgScoreDetail orgScoreDetail = new OrgScoreDetail();
        orgScoreDetail.setType(PERSON_TYPE);
        orgScoreDetail.setOrgCode(enterprise.getOrgCode());
        orgScoreDetail.setScore(score);
        //生成资质详细ID
        String quaDetailId = UUID.randomUUID().toString();
        orgScoreDetail.setDetailId(quaDetailId);
        orgScoreDetailService.insertOrgScoreDetail(orgScoreDetail,quaTempList);
        //打印企业最终资质人员得分日志
        printEndLog(enterprise, quaTempList, score, flag);
    }

    /**
     * 打印企业最终资质人员得分日志
     * @param enterprise
     * @param quaTempList
     * @param score
     * @param flag
     */
    private void printEndLog(EnterpriseInfo enterprise, ArrayList<QuaTemp> quaTempList, Double score, boolean flag) {
        OrgScoreTest orgScoreTest = new OrgScoreTest();
        orgScoreTest.setOrgCode(enterprise.getOrgCode());
        orgScoreTest.setOrgName(enterprise.getOrgName());
        orgScoreTest.setScore(score);
        quaInfoService.insertOrgScoreTest(orgScoreTest);
        System.out.println("------------企业:["+enterprise.getOrgName()+"],组织机构代码:["+enterprise.getOrgCode()+"],资质人员最终得分:"+score);
        System.out.print("所有资质合格情况:");
        if(flag){
            System.out.println("全部合格");
        }else{
            System.out.println("有资质不合格");
        }
        for (QuaTemp quaTemp : quaTempList) {
            Boolean qualified = quaTemp.getQualified();
            List<ZzPerson> zzUse = quaTemp.getZzPersonList();
            List<ZcPerson> zcUse = quaTemp.getZcPersonList();
            Long shortOfZzCount = quaTemp.getShortOfZzCount();
            Long shortOfZcCount = quaTemp.getShortOfZcCount();
            List<String> shortOfZcTypeList = quaTemp.getShortOfZcTypeList();
            List<ZzPerson> augmentZzPersonList = quaTemp.getAugmentZzPersonList();
            System.out.println("/////////////////////////////////////////////////////");
            System.out.println("资质名称:《"+quaTemp.getQuaInfo().getQuaName()+"》");
            System.out.println("合格情况:"+(qualified ? "合格" : "不合格"));
            System.out.print("已使用注册建造师:");
            for (ZzPerson zzPerson : zzUse) {
                System.out.print(zzPerson.getPname()+"("+zzPerson.getRegSpty()+",");
            }
            if(!augmentZzPersonList.isEmpty()){
                System.out.println("加分注册人员:");
                for (ZzPerson zzPerson : augmentZzPersonList) {
                    String regTypeId = zzPerson.getRegTypeId();
                    Double d = 0D;
                    if(ScoreEnum.FIRST.getRegTypeId().equals(regTypeId)){
                        d = ScoreEnum.FIRST.getScore();
                    }
                    if(ScoreEnum.SECOND.getRegTypeId().equals(regTypeId)){
                        d = ScoreEnum.SECOND.getScore();
                    }
                    System.out.println(zzPerson.getPname()+",("+zzPerson.getRegSpty()+"),加分:"+d);
                }
            }
            if(shortOfZzCount > 0){

                System.out.println("缺少注册人员:"+shortOfZzCount+"人,扣除"+DoubleUtils.mul(new BigDecimal(shortOfZzCount).doubleValue(),SUBSTRACT_SCORE)+"分");
            }
            System.out.println();
            System.out.println("已使用职称人员:");
            for (ZcPerson zcPerson : zcUse) {
                System.out.print(zcPerson.getPname()+"("+zcPerson.getCertSpty()+",");
            }
            if(shortOfZcCount > 0){
                System.out.println("缺少职称人员:"+shortOfZcCount+"人,扣除"+DoubleUtils.mul(new BigDecimal(shortOfZcCount).doubleValue(),SUBSTRACT_SCORE)+"分");
            }
            if(!shortOfZcTypeList.isEmpty()){
                System.out.print("缺少职称类别:");
                for (String spty : shortOfZcTypeList) {
                    System.out.print(spty+",");
                }
                System.out.println("扣除:"+ DoubleUtils.mul(new BigDecimal(shortOfZcTypeList.size()).doubleValue(), SUBSTRACT_SCORE) + "分");
            }
            System.out.println();
        }
    }

    /**
     * 减分
     * @param score
     * @param shortOfZcCount
     * @return
     */
    private Double subtractScore(Double score, Long shortOfZcCount) {
        if(DoubleUtils.sub(score,DoubleUtils.mul(SUBSTRACT_SCORE,new BigDecimal(shortOfZcCount).doubleValue())) < MIN_SOCRE){
            score = MIN_SOCRE;
        }else{
            score = DoubleUtils.sub(score,DoubleUtils.mul(SUBSTRACT_SCORE,new BigDecimal(shortOfZcCount).doubleValue()));
        }
        return score;
    }


    /**
     * 加分
     * @param score 原分数
     * @param zzPerson 注册人员
     * @return
     */
    private Double getAddScore(Double score, ZzPerson zzPerson) {
        if(ScoreEnum.FIRST.getRegTypeId().equals(zzPerson.getRegTypeId())){
            if(DoubleUtils.add(score,ScoreEnum.FIRST.getScore()) > MAX_SCORE)
                score = MAX_SCORE;
            else
                score = DoubleUtils.add(score,ScoreEnum.FIRST.getScore());
        }
        if(ScoreEnum.SECOND.getRegTypeId().equals(zzPerson.getRegTypeId())){
            if(DoubleUtils.add(score,ScoreEnum.SECOND.getScore()) > MAX_SCORE)
                score = MAX_SCORE;
            else
                score = DoubleUtils.add(score,ScoreEnum.SECOND.getScore());
        }
        return score;
    }

    /**
     * 资质整体是否符合规则
     * @param quaTempList
     * @return
     */
    public boolean allFlag(ArrayList<QuaTemp> quaTempList){
        boolean flag = true;
        for (QuaTemp quaTemp : quaTempList) {
            if(!quaTemp.getQualified()){
                flag = false;
                break;
            }
        }
        return flag;
    }

    /**
     * 符合标准资质处理
     * @param enterprise
     * @param quaTempList
     * @param zzPersonList
     * @param zcPersonList
     */
    private void conformToQua(EnterpriseInfo enterprise, ArrayList<QuaTemp> quaTempList, List<ZzPerson> zzPersonList, List<ZcPerson> zcPersonList) {
        A:
        for (QuaTemp quaTemp : quaTempList) {
            System.out.println();
            System.out.println();
            System.out.println();
            System.out.println("当前计算资质名称:《"+quaTemp.getQuaInfo().getQuaName()+"》");
            //已使用注册人员
            List<ZzPerson> zzUsePerson = quaTemp.getZzPersonList();
            //已使用职称人员
            List<ZcPerson> zcUsePersonList = quaTemp.getZcPersonList();
            //根据资质名称查询资质人员标准
            QuaPersionConfig quaPersionConfig = new QuaPersionConfig();
            quaPersionConfig.setQuaName(quaTemp.getQuaInfo().getQuaName());
            //资质人员标准参数
            List<QuaPersionConfig> quaPersionConfigList = quaPersionConfigService.selectQuaPersionConfigList(quaPersionConfig);
            if(!StringUtils.isNull(quaPersionConfigList) && !quaPersionConfigList.isEmpty()){
                //获取该资质算分标准
                QuaPersionConfig qpc = quaPersionConfigList.get(0);
                //获取注册建造师所需人数
                Long regNum = qpc.getRegNum();
                quaTemp.setHavePerson(regNum);
                //获取注册建造师专业信息
                String regSpty = qpc.getRegSpty();
                //获取注册建造师必要人数
                Long regNumAnd = qpc.getRegNumAnd();
                //获取注册建造师必要专业
                String regSptyAnd = qpc.getRegSptyAnd();
                //获取职称人员数量
                Long techNum = qpc.getTechNum();
                //获取职称人员专业
                String techSpty = qpc.getTechSpty();
                //注册建造师人数 职称人数为空 直接算合格
                if(regNum == null && techNum == null){
                    System.out.println("资质:《"+quaTemp.getQuaInfo().getQuaName()+"》没有标准直接合格");
                    quaTemp.setQualified(true);
                    continue A;
                }
                //注册建造师类别处理临时集合
                ArrayList<QuaPersonZzTemp> zzTempList = new ArrayList<>();
                //如果存在专业类别 验证
                if(!StringUtils.isEmpty(regSpty)){
                    //获取该资质规则
                    formatRegSpty(regSpty, zzTempList);
                    //获取符合该规则的注册建造师
                    getOrgHaveZzPerson(zzPersonList, zzTempList);
                    //打印注册建造师标准
                    printZzBz(enterprise, zzPersonList, regNum, regNumAnd, regSptyAnd, zzTempList);
                    //处理注册建造师类别
                    //判断必须有的注册建造师和专业
                    int sumPersonNum = 0;
                    for (QuaPersonZzTemp quaPersonZzTemp : zzTempList) {
                        sumPersonNum += quaPersonZzTemp.getHaveZzPerson().size();
                    }
                    if(!StringUtils.isEmpty(regSptyAnd)){
                        //有 判断必须有的注册建造否有符合的人数
                        for (QuaPersonZzTemp quaPersonZzTemp : zzTempList) {
                            String rs = quaPersonZzTemp.getRegSpty();
                            if(regSptyAnd.equals(rs)){
                                int size = quaPersonZzTemp.getHaveZzPerson().size();
                                if(size < regNumAnd){
                                    System.out.println("其中必须有的注册建造师类别("+regSptyAnd+")人数不足:缺少"+(regNumAnd - size)+"人,本次退出进行下一个资质");
                                    continue A;
                                }
                            }
                        }
                        //计算总人数是否符合
                        if(sumPersonNum < regNum){
                            System.out.println("注册建造师总人数不足:缺少"+(regNum - sumPersonNum)+"人,本次退出进行下一个资质");
                            continue A;
                        }
                    }else{
                        //直接计算总人数
                        if(regNum != null){
                            if(sumPersonNum < regNum){
                                System.out.println("缺少注册建造师:缺少"+(regNum - sumPersonNum)+"人,本次退出进行下一个资质");
                                continue A;
                            }
                        }
                    }
                }else{
                    if(regNum != null){
                        //打印注册建造师标准
                        printZzBz(enterprise, zzPersonList, regNum, regNumAnd, regSptyAnd, zzTempList);
                        //不存在类别验证人数
                        if(zzPersonList.size() < regNum){
                            System.out.println("缺少注册建造师:缺少"+(regNum - zzPersonList.size())+"人,本次退出进行下一个资质");
                            continue A;
                        }
                    }else{
                        //人数不存在 无标准
                        System.out.println("不存在建造师标准参数");
                    }
                }
                //如果存在职称人数
                if(techNum != null){
                    //打印职称标准
                    printZcBz(enterprise, zcPersonList, techNum, techSpty);
                    List<String> shortOfZcTypeList = quaTemp.getShortOfZcTypeList();
                    //判断类型
                    QuaPersonZcTemp quaPersonZcTemp = new QuaPersonZcTemp(techSpty);
                    if(quaPersonZcTemp.isNeedCompute()){
                        boolean compute = quaPersonZcTemp.compute(zcPersonList);
                        if(!compute){
                            System.out.print("职称类型不符合规则:缺少");
                            for (String s : shortOfZcTypeList) {
                                System.out.print(s+",");
                            }
                            System.out.println("本次退出进行下一个资质");
                            continue A;
                        }
                    }
                    //判断人数是否足够
                    if(zcPersonList.size() < techNum){
                        System.out.println("职称人员不足:缺少"+(techNum - zcPersonList.size())+"人,本次退出进行下一个资质");
                        continue A;
                    }
                }

                quaTemp.setQualified(true);

                //去除注册建造师不分类别
                if(StringUtils.isEmpty(regSpty)&&regNum != null){
                    int count = 0;
                    for (int i = 0; i < zzPersonList.size(); i++) {
                        if(count == regNum){
                            break;
                        }
                        ZzPerson zzPerson = zzPersonList.get(i);
                        if(!containsZzPerson(zzPerson,zzUsePerson)){
                            zzUsePerson.add(zzPerson);
                            count++;
                        }
                    }
                }
                //去除注册建造师分类别
                if(!StringUtils.isEmpty(regSpty)){
                    //符合规则 先减去其中必须的人数 剩余的人数轮训减
                    if(!StringUtils.isEmpty(regSptyAnd)){
                        //获取该类别注册建造师级别
                        String grade = getGrade(zzTempList,regSptyAnd);
                        //使用必须有的注册建造师
                        zzPersonUse(zzPersonList,zzUsePerson,regSptyAnd,grade,Integer.parseInt(regNumAnd+""));
                        regNum -= regNumAnd;
                    }
                    //轮询减去剩余人数
                    polling(zzPersonList,zzUsePerson,regNum,zzTempList);
                }

                //去除职称人员
                QuaPersonZcTemp quaPersonZcTemp = new QuaPersonZcTemp(techSpty);
                //需要计算类别
                if(quaPersonZcTemp.isNeedCompute()){
                    boolean compute = quaPersonZcTemp.compute(zcPersonList);
                    if(compute){
                        quaPersonZcTemp.useZcPerson(zcPersonList,zcUsePersonList,Integer.parseInt(techNum+""));
                    }
                }else{
                    //不需要计算类别
                    if(techNum!=null){
                        for (int i = 0; i < techNum; i++) {
                            ZcPerson zcPerson = zcPersonList.get(i);
                            zcUsePersonList.add(zcPerson);
                        }
                    }
                }

                //打印资质符合标准结果
                printLog(zzPersonList, zcPersonList, quaTemp, zcUsePersonList, regNum, techNum);
            }
        }
    }


    /**
     * 不符合标准的资质处理
     * @param enterprise
     * @param quaTempList
     * @param zzPersonList
     * @param zcPersonList
     */
    private void inconformityQua(EnterpriseInfo enterprise, ArrayList<QuaTemp> quaTempList, List<ZzPerson> zzPersonList, List<ZcPerson> zcPersonList) {
        for (QuaTemp quaTemp : quaTempList) {
            //筛选不合格资质
            Boolean qualified = quaTemp.getQualified();
            if(!qualified){
                System.out.println();
                System.out.println();
                System.out.println();
                System.out.println("不符合标准资质处理,资质名称:《"+quaTemp.getQuaInfo().getQuaName()+"》");
                //缺少注册建造师人数
                Long shortOfZzCount = 0L;
                //缺少职称人员人数
                Long shortOfZcCount = 0L;
                //已使用注册人员
                List<ZzPerson> zzUsePerson = quaTemp.getZzPersonList();
                //已使用职称人员
                List<ZcPerson> zcUsePersonList = quaTemp.getZcPersonList();
                //缺少职称类别
                List<String> shortOfZcTypeList = quaTemp.getShortOfZcTypeList();
                //根据资质名称查询资质人员标准
                QuaPersionConfig quaPersionConfig = new QuaPersionConfig();
                quaPersionConfig.setQuaName(quaTemp.getQuaInfo().getQuaName());
                //资质人员标准参数
                List<QuaPersionConfig> quaPersionConfigList = quaPersionConfigService.selectQuaPersionConfigList(quaPersionConfig);
                if(!StringUtils.isNull(quaPersionConfigList) && !quaPersionConfigList.isEmpty()){
                    //获取该资质算分标准
                    QuaPersionConfig qpc = quaPersionConfigList.get(0);
                    //获取注册建造师所需人数
                    Long regNum = qpc.getRegNum();
                    //获取注册建造师专业信息
                    String regSpty = qpc.getRegSpty();
                    //获取注册建造师必要人数
                    Long regNumAnd = qpc.getRegNumAnd();
                    //获取注册建造师必要专业
                    String regSptyAnd = qpc.getRegSptyAnd();
                    //获取职称人员数量
                    Long techNum = qpc.getTechNum();
                    //获取职称人员专业
                    String techSpty = qpc.getTechSpty();
                    //注册建造师类别处理临时集合
                    ArrayList<QuaPersonZzTemp> zzTempList = new ArrayList<>();
                    //如果存在专业类别 验证
                    if(!StringUtils.isEmpty(regSpty)){
                        //获取该资质规则
                        formatRegSpty(regSpty, zzTempList);
                        //获取符合该规则的注册建造师
                        getOrgHaveZzPerson(zzPersonList, zzTempList);
                        //打印注册建造师标准
                        printZzBz(enterprise, zzPersonList, regNum, regNumAnd, regSptyAnd, zzTempList);
                        //处理注册建造师类别
                        //判断必须有的注册建造师和专业
                        if(!StringUtils.isEmpty(regSptyAnd)){
                            //有 判断必须有的注册建造否有符合的人数
                            for (QuaPersonZzTemp quaPersonZzTemp : zzTempList) {
                                String rs = quaPersonZzTemp.getRegSpty();
                                if(regSptyAnd.equals(rs)){
                                    int size = quaPersonZzTemp.getHaveZzPerson().size();
                                    if(size < regNumAnd){
                                        //记录缺少注册建造师人数
                                        shortOfZzCount += regNumAnd - size;
                                        //去除该类别注册建造师
                                        //获取该类别注册建造师级别
                                        String grade = getGrade(zzTempList,regSptyAnd);
                                        zzPersonUse(zzPersonList,zzUsePerson,regSptyAnd,grade,size);
                                    }else{
                                        //获取该类别注册建造师级别
                                        String grade = getGrade(zzTempList,regSptyAnd);
                                        //直接减去人数
                                        zzPersonUse(zzPersonList,zzUsePerson,regSptyAnd,grade,Integer.parseInt(regNum+""));
                                    }
                                }
                            }
                            //剩余总人数 = 总人数 - 必须有的注册建造师人数
                            Long surplus = regNum - regNumAnd;
                            //轮询减去剩下的人 返回缺少的人数
                            Long shotOfCount = pollingSurplus(zzPersonList,zzUsePerson,zzTempList,surplus);
                            shortOfZzCount += shotOfCount;
                        }else{
                            //轮询减去注册建造师 返回缺少的人数
                            if(regNum != null){
                                Long shotOfCount = pollingSurplus(zzPersonList,zzUsePerson,zzTempList,regNum);
                                shortOfZzCount += shotOfCount;
                            }
                        }
                    }else{
                        if(regNum != null){
                            //打印注册建造师标准
                            printZzBz(enterprise, zzPersonList, regNum, regNumAnd, regSptyAnd, zzTempList);
                            //不存在类别验证人数
                            if(zzPersonList.size() < regNum){
                                //记录缺少人数
                                shortOfZzCount += regNum - zzPersonList.size();
                                //减去注册建造师
                                reduceZzPerson(zzPersonList, zzUsePerson, Long.parseLong(zzPersonList.size()+""));
                            }else{
                                reduceZzPerson(zzPersonList, zzUsePerson, regNum);
                            }
                        }
                    }



                    //记录资质缺少注册建造师
                    quaTemp.setShortOfZzCount(shortOfZzCount);

                    //打印职称标准
                    if(techNum != null){
                        printZcBz(enterprise, zcPersonList, techNum, techSpty);
                        //判断类型
                        QuaPersonZcTemp quaPersonZcTemp = new QuaPersonZcTemp(techSpty);
                        if(quaPersonZcTemp.isNeedCompute()){
                            boolean compute = quaPersonZcTemp.compute(zcPersonList);
                            if(!compute){
                                shortOfZcTypeList.addAll(quaPersonZcTemp.getNoHaveList());
                            }
                        }

                        //判断人数是否足够
                        if(zcPersonList.size() < techNum){
                            //人数不够直接减人 记录缺少人数
                            shortOfZcCount += techNum - zcPersonList.size();
                            zcUsePersonList.addAll(zcPersonList);
                        }else{
                            quaPersonZcTemp.useZcPerson(zcPersonList,zcUsePersonList,Integer.parseInt(techNum+""));
                        }

                        //记录注册建造师缺少人数
                        quaTemp.setShortOfZcCount(shortOfZcCount);
                    }
                    //打印资质符合标准结果
                    printLog(zzPersonList, zcPersonList, quaTemp, zcUsePersonList, regNum, techNum);
                }
            }
        }
    }

    /**
     * 减少资质人员不分类别
     * @param zzPersonList
     * @param zzUsePerson
     * @param personCount
     */
    private void reduceZzPerson(List<ZzPerson> zzPersonList, List<ZzPerson> zzUsePerson, Long personCount) {
        for (int i = 0; i < personCount; i++) {
            zzUsePerson.add(zzPersonList.get(i));
        }
    }

    /**
     * 轮询减少注册建造师 返回缺少的人数
     * @param zzPersonList 注册建造师
     * @param zzUsePerson 已使用注册建造师
     * @param zzTempList 资质需要注册建造师类别
     * @param personCount 减去多少人
     * @return
     */
    private Long pollingSurplus(List<ZzPerson> zzPersonList, List<ZzPerson> zzUsePerson,ArrayList<QuaPersonZzTemp> zzTempList, Long personCount) {
        boolean f = true;
        int count = 0;
        int oldCount;
        while (f){
            if(StringUtils.isNull(zzPersonList)||zzPersonList.isEmpty()){
                break;
            }
            oldCount = count;
            B:
            for (QuaPersonZzTemp quaPersonZzTemp : zzTempList) {
                //减去人数 并添加到已使用人数
                for(int j = 0; j < zzPersonList.size(); j++){
                    ZzPerson zzPerson = zzPersonList.get(j);
                    if(StringUtils.isNull(zzPerson.getRegSpty())){
                        continue;
                    }
                    //验证类别
                    boolean contains = zzPerson.getRegSpty().contains(quaPersonZzTemp.getRegSpty());
                    if(contains) {
                        //验证级别
                        if (!StringUtils.isEmpty(quaPersonZzTemp.getRegSptyGrade())) {
                            //符合级别才可以减
                            if (!StringUtils.isEmpty(zzPerson.getRegTypeId()) && quaPersonZzTemp.getRegSptyGrade().equals(zzPerson.getRegTypeId())) {
                                if (!containsZzPerson(zzPerson, zzUsePerson)) {
                                    zzUsePerson.add(zzPerson);
                                    count++;
                                    break;
                                }
                            }
                        } else {
                            if (!containsZzPerson(zzPerson, zzUsePerson)) {
                                zzUsePerson.add(zzPerson);
                                count++;
                                break;
                            }
                        }
                    }
                }
                if(count == personCount){
                    f = false;
                    break B;
                }
            }
            if(oldCount == count){
                f = false;
            }
        }
        return count == personCount ? 0 : personCount - count;
    }

    /**
     * 获取注册建造师级别
     * @param zzTempList 注册建造师临时处理类
     * @return
     */
    private String getGrade(ArrayList<QuaPersonZzTemp> zzTempList,String regSptyAnd) {
        String grade = null;
        for (QuaPersonZzTemp quaPersonZzTemp : zzTempList) {
            if(regSptyAnd.equals(quaPersonZzTemp.getRegSpty())){
                grade = quaPersonZzTemp.getRegSptyGrade();
            }
        }
        return grade;
    }

    /**
     * 打印注册建造师标准
     * @param enterprise
     * @param zzPersonList
     * @param regNum
     * @param regNumAnd
     * @param regSptyAnd
     * @param zzTempList
     */
    private void printZzBz(EnterpriseInfo enterprise, List<ZzPerson> zzPersonList, Long regNum, Long regNumAnd, String regSptyAnd, ArrayList<QuaPersonZzTemp> zzTempList) {
        if(regNum!=null){
            System.out.print("拥有注册建造师:");
            for (ZzPerson zzPerson : zzPersonList) {
                System.out.print(zzPerson.getPname()+"("+zzPerson.getRegSpty()+"),");
            }
            System.out.println();
            System.out.print("资质注册建造师规则:");
            for (QuaPersonZzTemp quaPersonZzTemp : zzTempList) {
                if(StringUtils.isEmpty(quaPersonZzTemp.getRegSptyGrade())){
                    System.out.print(quaPersonZzTemp.getRegSpty()+",");
                }else{
                    System.out.print(quaPersonZzTemp.getRegSpty()+"("+quaPersonZzTemp.getRegSptyGrade()+")"+",");
                }
            }
            System.out.print("不少于"+regNum+"人");
            if(!StringUtils.isEmpty(regSptyAnd)){
                System.out.print(",其中:"+regSptyAnd+"不少于"+regNumAnd+"人");
            }
            System.out.println();
        }
    }

    /**
     * 打印职称标准参数
     * @param enterprise
     * @param zcPersonList
     * @param techNum
     * @param techSpty
     */
    private void printZcBz(EnterpriseInfo enterprise, List<ZcPerson> zcPersonList, Long techNum, String techSpty) {
        if(techNum!=null){
            System.out.print("拥有职称人员:");
            for (ZcPerson zcPerson : zcPersonList) {
                System.out.print(zcPerson.getPname()+"("+zcPerson.getCertSpty()+"),");
            }
            System.out.println();
            QuaPersonZcTemp qpt = new QuaPersonZcTemp(techSpty);
            List<String> mustList = qpt.getMustList();
            List<String> noMustList = qpt.getNoMustList();
            System.out.print("资质职称人员规则:");
            System.out.print("职称人员不少于"+techNum+"人");
            if(!mustList.isEmpty()){
                System.out.print("必须有");
                for (String must : mustList) {
                    System.out.print(must+"、");
                }
            }
            if(!noMustList.isEmpty()){
                System.out.print("以下职称类别:(");
                for (String noMust : noMustList) {
                    System.out.print(noMust+",");
                }
                System.out.println(")必须有一人");
            }else{
                System.out.println();
            }
        }
    }

    /**
     * 打印资质符合标准结果
     * @param zzPersonList
     * @param zcPersonList
     * @param quaTemp
     * @param zcUsePersonList
     * @param regNum
     * @param techNum
     */
    private void printLog(List<ZzPerson> zzPersonList, List<ZcPerson> zcPersonList, QuaTemp quaTemp,List<ZcPerson> zcUsePersonList, Long regNum, Long techNum) {
        System.out.println("资质处理结果:《"+quaTemp.getQuaInfo().getQuaName()+"》");
        if(regNum!=null){
            System.out.print("资质已使用注册人员:");
            List<ZzPerson> z = quaTemp.getZzPersonList();
            for (ZzPerson zzPerson : z) {
                System.out.print(zzPerson.getPname()+"("+zzPerson.getRegSpty()+"),");
            }
            System.out.println();
            System.out.println("缺少注册人员:"+quaTemp.getShortOfZzCount()+"人");
            System.out.print("企业剩余人注册员:");
            for (ZzPerson zzPerson : zzPersonList) {
                System.out.print(zzPerson.getPname()+"("+zzPerson.getRegSpty()+"),");
            }
            System.out.println();
        }
        if(techNum!=null){
            System.out.print("已使用职称人员:");
            for (ZcPerson zcPerson : zcUsePersonList) {
                System.out.print(zcPerson.getPname()+"("+zcPerson.getCertSpty()+"),");
            }
            System.out.println();
            System.out.println("缺少职称人员:"+quaTemp.getShortOfZcCount()+"人");
            System.out.print("企业剩余职称人员:");
            for (ZcPerson zcPerson : zcPersonList) {
                System.out.print(zcPerson.getPname()+"("+zcPerson.getCertSpty()+"),");
            }
            System.out.println();
            System.out.print("缺少职称类别:");
            for (String s : quaTemp.getShortOfZcTypeList()) {
                System.out.print(s+",");
            }
            System.out.println();
        }
    }

    /**
     * 轮询减少人数
     * @param zzPersonList 注册人员集合
     * @param zzUsePerson 已经使用注册人员
     * @param personCount 减少人数
     * @param zzTempList 标准里的所有类别
     */
    private void polling(List<ZzPerson> zzPersonList, List<ZzPerson> zzUsePerson, Long personCount, ArrayList<QuaPersonZzTemp> zzTempList) {
        int count = 0;
        int oldCount;
        while (true){
            oldCount = count;
            if(StringUtils.isNull(zzPersonList)||zzPersonList.isEmpty()){
                break;
            }
            B:
            for (QuaPersonZzTemp quaPersonZzTemp : zzTempList) {
                //减去人数 并添加到已使用人数
                for(int j = 0; j < zzPersonList.size(); j++){
                    ZzPerson zzPerson = zzPersonList.get(j);
                    if(StringUtils.isNull(zzPerson.getRegSpty())){
                        continue;
                    }
                    //验证类别
                    boolean contains = zzPerson.getRegSpty().contains(quaPersonZzTemp.getRegSpty());
                    if(contains){
                        //验证级别
                        if(!StringUtils.isEmpty(quaPersonZzTemp.getRegSptyGrade())){
                            //符合级别才可以减
                            if(!StringUtils.isEmpty(zzPerson.getRegTypeId())&&quaPersonZzTemp.getRegSptyGrade().equals(zzPerson.getRegTypeId())){
                                if(!containsZzPerson(zzPerson,zzUsePerson)){
                                    zzUsePerson.add(zzPerson);
                                    count++;
                                    break ;
                                }
                            }
                        }else{
                            if(!containsZzPerson(zzPerson,zzUsePerson)){
                                zzUsePerson.add(zzPerson);
                                count++;
                                break ;
                            }
                        }
                    }
                }
                if(count == personCount){
                    break;
                }
            }
            if(count == personCount){
                break;
            }
            if(oldCount == count){
                break;
            }
        }
    }

    /**
     * 资质使用注册人员
     * @param zzPersonList 资质人员
     * @param zzUsePerson 资质使用人员
     * @param regSpty 减去人员的注册类别
     * @param size 减去人员的数量
     * @param grade 注册建造师级别
     */
    private void zzPersonUse(List<ZzPerson> zzPersonList, List<ZzPerson> zzUsePerson, String regSpty,String grade, int size) {
        int count = 0;
        for(int j = 0; j < zzPersonList.size(); j++){
            ZzPerson zzPerson = zzPersonList.get(j);
            //人员类别不为空 人员类别和资质需要类别相同
            if(!StringUtils.isEmpty(zzPerson.getRegSpty())&&zzPerson.getRegSpty().contains(regSpty)){
                if(StringUtils.isEmpty(grade)){
                    if(!containsZzPerson(zzPerson,zzUsePerson)){
                        zzUsePerson.add(zzPerson);
                        count ++;
                    }
                }else{
                    if(!StringUtils.isEmpty(zzPerson.getRegSpty())&&zzPerson.getRegSpty().contains(regSpty) && zzPerson.getRegTypeId().equals(grade)){
                        if(!containsZzPerson(zzPerson,zzUsePerson)){
                            zzUsePerson.add(zzPerson);
                            count ++;
                        }
                    }
                }

            }
            if(count == size){
                break;
            }
        }
    }

    /**
     * 获取企业拥有 符合该资质类别 和 注册建造师级别的人数
     * @param zzPersonList 企业资质人员
     * @param zzTempList  注册建造师类别处理临时集合
     */
    private void getOrgHaveZzPerson(List<ZzPerson> zzPersonList, ArrayList<QuaPersonZzTemp> zzTempList) {
        for (QuaPersonZzTemp quaPersonZzTemp : zzTempList) {
            //获取企业拥有该专业的人数
            List<ZzPerson> haveZzPerson = quaPersonZzTemp.getHaveZzPerson();
            //专业
            String r = quaPersonZzTemp.getRegSpty();
            //级别
            String g = quaPersonZzTemp.getRegSptyGrade();
            for (ZzPerson zzPerson : zzPersonList) {
                String r1 = zzPerson.getRegSpty();
                String g1 = zzPerson.getRegTypeId();
                if(!StringUtils.isEmpty(g)){
                    //包含级别
                    if(!StringUtils.isEmpty(r1)&&r1.contains(r)&&!StringUtils.isEmpty(g1)&&g1.contains(g)){
                        haveZzPerson.add(zzPerson);
                    }
                }else{
                    //不包含级别
                    if(!StringUtils.isEmpty(r1)&&r1.contains(r)){
                        haveZzPerson.add(zzPerson);
                    }
                }
            }
        }
    }

    /**
     * 格式化 注册人员类别  根据规则切割    专业,级别|专业,级别
     * @param regSpty
     * @param zzTempList
     */
    private void formatRegSpty(String regSpty, ArrayList<QuaPersonZzTemp> zzTempList) {
        if(regSpty.contains(REG_SPTY_S)){
            //包含多个类别 类别和注册建造师级别
            String[] regSptyArr = regSpty.split("["+REG_SPTY_S+"]");
            for (String rs : regSptyArr) {
                setZzTemp(rs, zzTempList);
            }
        }else{
            //单个类别
            //注册建造师级别
            setZzTemp(regSpty, zzTempList);
        }
    }

    /**
     * 装配资质人员临时信息
     * @param regSpty 注册人员专业类别
     * @param zzTempList 临时集合
     */
    private void setZzTemp(String regSpty, ArrayList<QuaPersonZzTemp> zzTempList) {
        if(regSpty.contains(REG_SPTY_D)){
            //有级别
            String[] rsa = regSpty.split("["+REG_SPTY_D+"]");
            QuaPersonZzTemp quaPersonZzTemp = new QuaPersonZzTemp();
            quaPersonZzTemp.setRegSpty(rsa[0]);
            quaPersonZzTemp.setRegSptyGrade(rsa[1]);
            zzTempList.add(quaPersonZzTemp);
        }else{
            //没有级别
            QuaPersonZzTemp quaPersonZzTemp = new QuaPersonZzTemp();
            quaPersonZzTemp.setRegSpty(regSpty);
            zzTempList.add(quaPersonZzTemp);
        }
    }

    /**
     * 填充资质计算临时信息
     * @param quaInfoList 资质集合
     * @param quaTempList 临时计算集合
     */
    private void fillQuaTempList(List<QuaInfo> quaInfoList, ArrayList<QuaTemp> quaTempList) {
        for (QuaInfo qua : quaInfoList) {
            QuaTemp quaTemp = new QuaTemp();
            quaTemp.setQuaInfo(qua);
            quaTempList.add(quaTemp);
        }
    }

    /**
     * 获取资质得分
     * @param quaRules 资质规则
     * @param enterprise 企业信息
     * @param quaInfoList 企业资质集合
     * @return
     */
    private Double getQuaScore(List<QuaRule> quaRules, EnterpriseInfo enterprise, List<QuaInfo> quaInfoList) {
        Double quaScore = 0d;
        A:
        for (QuaRule quaRule : quaRules) {
            for (QuaInfo qua : quaInfoList) {
                //等级等于空不验证等级
                if(StringUtils.isEmpty(quaRule.getLevel())){
                    if(quaRule.getName().equals(qua.getQuaName())){
                        //资质名称相同得分
                        quaScore = Double.parseDouble(quaRule.getScore());
                        insertOrgQuaDetail(enterprise, quaScore, quaRule, qua);
                        break A;
                    }
                }else{
                    //验证等级
                    if(quaRule.getName().equals(qua.getQuaName())&&quaRule.getLevel().equals(qua.getQuaRank())){
                        //资质名称相同 等级相同 得分
                        quaScore = Double.parseDouble(quaRule.getScore());
                        insertOrgQuaDetail(enterprise, quaScore, quaRule, qua);
                        //记录得分明细
                        break A;
                    }
                }
            }
        }
        return quaScore;
    }

    /**
     * 添加企业得分 资质得分详细
     * @param enterprise 企业信息
     * @param quaScore 资质得分
     * @param quaRule 得分规则
     * @param qua 资质
     */
    private void insertOrgQuaDetail(EnterpriseInfo enterprise, Double quaScore, QuaRule quaRule, QuaInfo qua) {
        //记录得分明细
        OrgScoreDetail orgScoreDetail = new OrgScoreDetail();
        orgScoreDetail.setType(QUA_TYPE);
        orgScoreDetail.setOrgCode(enterprise.getOrgCode());
        orgScoreDetail.setScore(quaScore);
        //生成资质详细ID
        String quaDetailId = UUID.randomUUID().toString();
        orgScoreDetail.setDetailId(quaDetailId);
        orgScoreDetail.setConfigId(quaRule.getId());
        orgScoreDetailService.insertOrgScoreDetail(orgScoreDetail,qua);

    }
}
